﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;

namespace ADO_QLNS.Utils
{
    // Day la lop Concrete Factory trong Abstract Factory
    public class SqlDataProvider : AbstractFactory_ADO
    {
        public SqlDataProvider()
        {
            // Load cau hinh connetion string
            ConnectionString = ConfigurationManager.GetConfig("ConnectionString", "QLNS");
        }

        public override void CreateConnection()
        {
            base.Connection = new SqlConnection(ConnectionString);
        }

        public override void CreateCommand(string SqlString)
        {
            base.Command = new SqlCommand(SqlString, (SqlConnection)Connection);
        }

        public override void CreateAdapter(string SqlString)
        {
            base.Adapter = new SqlDataAdapter(SqlString, (SqlConnection)Connection);
        }
    }
}
